package com.kgc.service.impl;

import com.kgc.mapper.UserMapper;
import com.kgc.pojo.User;
import com.kgc.pojo.UserExample;
import com.kgc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User selectUserLogin(String userName, String password) {
        UserExample userExample=new UserExample();
        UserExample.Criteria userCriteria=userExample.createCriteria();
        userCriteria.andUserNameEqualTo(userName);
        userCriteria.andPasswordEqualTo(password);
        List<User> users=userMapper.selectByExample(userExample);
        if (users==null||users.size()==0){
            return null;
        }
        return users.get(0);
    }
}
